package com.banmao.c03_baseUsage;

import com.banmao.c03_baseUsage.entity.Dog;
import com.banmao.c03_baseUsage.entity.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Map;

// Bean 属性注入
@Slf4j
public class Demo03 {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans03.xml");

        Dog dog = ctx.getBean("dog", Dog.class);
        log.info("简单属性注入 dog ==> {}", dog);

        User user = ctx.getBean("user", User.class);
        log.info("复杂属性注入 user ==> {}", user);

        Map<String, Dog> beansOfType = ctx.getBeansOfType(Dog.class);
        System.out.println(beansOfType.values().size());
    }

}
